package com.wd.jdbc;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

import javax.sql.DataSource;

import org.springframework.context.support.GenericXmlApplicationContext;

public class JdbcPoolTest {

	public static void main(String[] args) {
		GenericXmlApplicationContext context = new GenericXmlApplicationContext();
		context.setValidating(false);
		context.load("classpath*:context/applicationContext*.xml");
		
		DataSource ds = (DataSource) context.getBean("dataSource");
		Connection con = null;
		try {
			con = ds.getConnection();
			Statement st = con.createStatement();
			ResultSet rs = st.executeQuery("select  loginName from wsp_users");
			while (rs.next()) {
				System.out.println("loginName: " + rs.getString("loginName"));
			}
			rs.close();
			st.close();
		} catch (SQLException ex) {
			ex.printStackTrace();
		} finally {
			if (con != null)
				try {
					con.close();
				} catch (Exception ignore) {
				}
		}
	}
}
